﻿using Common.EntityValidation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace TestMvc.Models
{
    public class Student
    {

        [NotNull(ErrorMessage = "Id是必须的")]    //验证非空，自定义ErroMessage
        public string Id { get; set; }


        [LengthAttribute(Max = 10, ErrorMessage = "个人介绍的长度")] //字符长度限制
        public string Introduce { get; set; }  //个人介绍


        [Range(Min =1,Max =120)]      //数值类型大小区间限制，最小，最大
        public int Age { get; set; }


        [Range( Min = "1900-10-10",Max = "2100-10-10")]   //字符类型的区间
        public string Birthday { get; set;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          }


        [Chinese]
        public string Name { get; set; }  //只能是中文



        [In(Range = "高中生,初中生,小学生")]
        public string StudentType { get; set; }//只能是  "高中生","初中生","小学生" 之一


      



        [DbValidation(Sql = "select*from dbo.[data] where id=@ClassId")]  //数据库验证，验证班级Id  ClassId是否存在于数据库中
        public string ClassId { get; set; }



        [Mobile]
        public string CellPhone { get; set; }


        [Email]

        public string Email { get; set; }

        [IdCard]
        public string IdCard { get; set; }



        [InEnum(RangeType = typeof(StuState))]  //只能是属于枚举中的值 ,0 或者 2或者4
        public int StuState { get; set; }
    }

    public enum StuState
    {

        上学中 = 0,
        肄业 = 2,
        退学 = 4,


    }
}